<?php
/**
 * The Template for displaying all single posts.
 *
 * @package WordPress
 * @subpackage MIP
 * @since MIP 1
 */

get_header(); ?>
<?php
	/* Queue the first post, that way we know
	 * what date we're dealing with (if that is the case).
	 *
	 * We reset this later so we can run the loop
	 * properly with a call to rewind_posts().
	 */
	if ( have_posts() )
		the_post();
		
	$check_ID = get_the_ID();
	$check_pt =  get_post_type( get_the_ID() );
	rewind_posts();
?>
	<div id="header_inner">
		<div id="headertext">
			<h1 class="pagetitle">
				<?php
				if($check_pt == 'portfolio' ){
					echo the_terms( get_the_ID(), 'portfoliocat', '', ', ');
				}else{
					$category = get_the_category(); 
					echo $category[0]->cat_name;
				}
				?>
			</h1>
		</div>
	</div>

	<div id="container_content">
	<div id="padding_content">
		<div id="maincontent">
			<div id="main">
				<div id="content">
		
				<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>


				<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
					<h2 class="entry-title"><?php the_title(); ?></h2>
					<?php if($check_pt == 'portfolio' ){ ?>
					<br />
					<?php } else { ?>
					
					<div class="entry-meta">
						<div class="metadata">
						<span class="author"> 
						<?php  the_time('F j') ?> <?php _e('in');?> <?php the_category(', ') ?>  <?php _e('by');?> 
						<?php _e('by');?> <?php the_author();?> | <?php comments_popup_link(__('No Comments '), __('1 Comment '), __('% Comments ')); ?></span>
						</div>
					</div><!-- .entry-meta -->
					<?php } ?>

					<div class="entry-content">
						<?php the_content(); ?>
						<?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:' ), 'after' => '</div>' ) ); ?>
					</div><!-- .entry-content -->


					<?php if($check_pt != 'portfolio' ): ?>
					<?php if ( get_the_author_meta( 'description' ) ) : // If a user has filled out their description, show a bio on their entries  ?>
					<div id="entry-author-info">
					<div id="entry-author-info2">
						<div id="author-avatar">
							<?php echo get_avatar( get_the_author_meta( 'user_email' ), apply_filters( 'ts_author_bio_avatar_size', 60 ) ); ?>
						</div><!-- #author-avatar -->
						<div id="author-description">
							<h2><?php printf( esc_attr__( 'About %s' ), get_the_author() ); ?></h2>
							<?php the_author_meta( 'description' ); ?>
							<div id="author-link">
								<a href="<?php echo get_author_posts_url( get_the_author_meta( 'ID' ) ); ?>">
									<?php printf( __( 'View all posts by %s <span class="meta-nav">&rarr;</span>' ), get_the_author() ); ?>
								</a>
							</div><!-- #author-link	-->
						</div><!-- #author-description -->
					</div><!-- #entry-author-info2 -->
					</div><!-- #entry-author-info -->
					<?php endif; ?>
					<?php endif; ?>

					<div class="entry-utility">
						<?php ts_posted_in(); ?>
						<?php edit_post_link( __( 'Edit' ), '<span class="edit-link">', '</span>' ); ?>
					</div><!-- .entry-utility -->
				</div><!-- #post-## -->

				<?php comments_template( '', true ); ?>

				<?php endwhile; // end of the loop. ?>

					</div><!-- end of content -->
			</div><!-- end of main -->
			<div id="side">
				<?php get_sidebar(); ?>
			</div><!-- end of side -->
		</div><!-- end of maincontent -->
	</div>
	<div class="clr"></div>
	</div>
	<!-- END OF CONTENT -->
	
	</div><!-- end of centercolumn -->
</div><!-- end of main container -->
<?php get_footer(); ?>
